package com.guaoran.interview.spring.aop.service.proxy.jdk;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

/**
 * @author : 孤傲然
 * @description : jdk 动态代理
 * @date :2020/1/7 15:03
 */
public class JdkProxy implements InvocationHandler {
    public Object proxy;

    public Object getProxy(Object proxy){
        this.proxy = proxy;
        return Proxy.newProxyInstance(proxy.getClass().getClassLoader(),proxy.getClass().getInterfaces(),this);
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        System.err.println("1111");
        method.invoke(this.proxy,args);
        System.err.println("222");
        return null;
    }
}
